package ${packageCode}.func.vx.${moduleMapperCode}.${businessCode?uncap_first};

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;
import ${packageCode}.${moduleMapperCode}.service.${businessCode}Service;
import top.cardone.context.ApplicationContextHolder;
import top.cardone.core.util.func.Func1;
import top.cardone.data.support.PageSupport;

import java.util.List;
import java.util.Map;

/**
 * ${businessName!} - 查询
 */
@Component("/vx/${moduleMapperCode}/${businessCode?uncap_first}/r0004.json")
public class R0004Func implements Func1<Object, Map<String, Object>> {
    private Table<String, String, String> inputConfigTable;
    private Table<String, String, String> outConfigTable;

    public R0004Func() {
        inputConfigTable = HashBasedTable.create();
<#if (entityMapper??) && (entityMapper.fieldMapperMap??)>
    <#list entityMapper.fieldMapperMap?values as fieldMapper>
		inputConfigTable.put("${fieldMapper.code}", "funcBeanId", "escapeSqlFunc");
    </#list>
</#if>

        outConfigTable = HashBasedTable.create();
<#if (entityMapper??) && (entityMapper.fieldMapperMap??)>
    <#list entityMapper.fieldMapperMap?values as fieldMapper>
		outConfigTable.put("${fieldMapper.columnName}", "newName", "${fieldMapper.code}");
    </#list>
</#if>
    }
	
    @Override
    public Object func(Map<String, Object> inputMap) {
        inputMap.putAll(top.cardone.context.util.MapUtils.newHashMap(inputMap, inputConfigTable));
		
        validate(inputMap);
		
        Page<Map<String, Object>> ${businessCode?uncap_first}Page = ApplicationContextHolder.getBean(${businessCode}Service.class).page(inputMap);

        List<Map<String, Object>> newContent = top.cardone.context.util.ListUtils.newArrayList(${businessCode?uncap_first}Page.getContent(), outConfigTable);

        return ApplicationContextHolder.getBean(PageSupport.class).newMap(newContent, inputMap, ${businessCode?uncap_first}Page.getTotalElements());
    }
	
    private  void validate(Map<String,Object>  inputMap){

    }
}